# WebSocket 服务构建脚本 (PowerShell)

Write-Host "构建 WebSocket 服务..." -ForegroundColor Green

# 检查 Go 是否安装
try {
    $goVersion = go version
    Write-Host "Go 版本: $goVersion" -ForegroundColor Green
} catch {
    Write-Host "错误: Go 未安装，请先安装 Go 1.21 或更高版本" -ForegroundColor Red
    exit 1
}

# 构建
Write-Host "正在构建..." -ForegroundColor Green
$env:GOOS = "windows"
$env:GOARCH = "amd64"
go build -o websocket-server.exe main.go

if ($LASTEXITCODE -eq 0) {
    Write-Host "构建成功: websocket-server.exe" -ForegroundColor Green
    Write-Host "运行: .\websocket-server.exe" -ForegroundColor Yellow
} else {
    Write-Host "构建失败" -ForegroundColor Red
    exit 1
}

